<template>
    <div>
        <h2>模块测试(namespaced:true)</h2>

        <!-- 手搓写法 -->
        <!-- <p>user:{{ $store.state.mdB.user }}</p>
        <p>token:{{ $store.state.mdB.token }}</p> -->
        <!-- 错误示范 
         <p>token:{{ $store.getters.mdB.isLogin }}</p>
         -->

         <!-- <p>token:{{ $store.getters["mdB/isLogin"] }}</p> 
        <p>
            <button @click="$store.commit('mdB/updateInfo',{user:'c123123'})">更新用户</button>
        </p>
        <p>
            <button @click="$store.dispatch('mdB/loginAndUpdateInfo')">模拟登录</button>
        </p> -->


        <p>user:{{ user }}</p>
        <p>token:{{ token }}</p>
        <p>a1-b1:{{ a1 }}----{{ b1 }}</p>

         <p>isLogin:{{ isLogin }}</p> 
        <p>
            <button @click="updateInfo({user:'c123123'})">更新用户</button>
        </p>
        <p>
            <button @click="loginAndUpdateInfo()">模拟登录</button>
        </p>


    </div>
</template>

<script>
    import {mapState,mapGetters,mapMutations,mapActions} from "vuex";

    export default {
        computed:{
            // ...mapState({
            //     user:(state)=>state.mdB.user,  // 从根store的state开始取值
            //     token:(state)=>state.mdB.token
            // })

            ...mapState("mdB",["user","token"]), // 从根store下的state的mdB模块的开始取值
            ...mapState("mdB/mdB_1",["a1","b1"]), // 从根store下的state的mdB模块的开始取值
            ...mapGetters("mdB",["isLogin"])
        },
        methods:{
            ...mapMutations("mdB",["updateInfo"]),
            ...mapActions("mdB",["loginAndUpdateInfo"])
        },
        mounted(){
            console.log("当前实例",this);
            console.log("当前实例$store",this.$store);
        }
    }
</script>

<style lang="scss" scoped>

</style>